
<template>
    <el-table :data="tableData" :span-method="objectSpanMethod" border style="width: 100%; margin-top: 20px">
        <el-table-column prop="id" label="ID" width="180" />
        <el-table-column prop="name" label="Name" />
        <el-table-column prop="amount1" label="Amount 1" />
        <el-table-column prop="amount2" label="Amount 2" />
        <el-table-column prop="amount3" label="Amount 3" />
    </el-table>

    <!-- <el-table :data="tableData2" style="width: 100%; margin-bottom: 20px" row-key="id" border default-expand-all>
        <el-table-column prop="date" label="Date" sortable />
        <el-table-column prop="name" label="Name" sortable />
        <el-table-column prop="address" label="Address" sortable />
    </el-table> -->
</template>

<script setup lang="ts">
import { TableColumnCtx } from 'element-plus'
import { ref } from 'vue'

interface User {
    id: string
    name: string
    amount1: string
    amount2: string
    amount3: number
}

interface SpanMethodProps {
    row: User
    column: TableColumnCtx<User>
    rowIndex: number
    columnIndex: number
}
const objectSpanMethod = ({
    row,
    column,
    rowIndex,
    columnIndex,
}: SpanMethodProps) => {
    // if (columnIndex === 1) {
    //     if (rowIndex === 0) {
    //         console.log('rowIndex: ', rowIndex)
    //         return {
    //             rowspan: 5,
    //             colspan: 1,
    //         }
    //     } else {
    //         return {
    //             rowspan: 1,
    //             colspan: 1,
    //         }
    //     }
    // }
}

const tableData: User[] = [
    {
        id: '12987122',
        name: 'Tom',
        amount1: '234',
        amount2: '3.2',
        amount3: 10,
    },
    {
        id: '12987123',
        name: 'Eom',
        amount1: '165',
        amount2: '4.43',
        amount3: 12,
    },
    {
        id: '12987124',
        name: 'Tom',
        amount1: '324',
        amount2: '1.9',
        amount3: 9,
    },
    {
        id: '12987125',
        name: 'Aom',
        amount1: '621',
        amount2: '2.2',
        amount3: 17,
    },
    {
        id: '12987126',
        name: 'Aom',
        amount1: '539',
        amount2: '4.1',
        amount3: 15,
    },
    {
        id: '12987127',
        name: 'Tom',
        amount1: '539',
        amount2: '4.1',
        amount3: 15,
    },
    {
        id: '12987128',
        name: 'Aom',
        amount1: '539',
        amount2: '4.1',
        amount3: 15,
    },
    {
        id: '12987129',
        name: 'Eom',
        amount1: '539',
        amount2: '4.1',
        amount3: 15,
    },
    {
        id: '12987130',
        name: 'Aom',
        amount1: '539',
        amount2: '4.1',
        amount3: 15,
    },
]
interface User2 {
  id: number
  date: string
  name: string
  address: string
  hasChildren?: boolean
  children?: User[]
}

const tableData2: User2[] = [
  {
    id: 1,
    date: '2016-05-02',
    name: 'wangxiaohu',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    id: 2,
    date: '2016-05-04',
    name: 'wangxiaohu',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    id: 3,
    date: '2016-05-01',
    name: 'wangxiaohu',
    address: 'No. 189, Grove St, Los Angeles',
    children: [
      {
        id: 31,
        date: '2016-05-01',
        name: 'wangxiaohu',
        address: 'No. 189, Grove St, Los Angeles',
      },
      {
        id: 32,
        date: '2016-05-01',
        name: 'wangxiaohu',
        address: 'No. 189, Grove St, Los Angeles',
      },
    ],
  },
  {
    id: 4,
    date: '2016-05-03',
    name: 'wangxiaohu',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
</script>

<style scoped>
.read-the-docs {
    color: #888;
}
</style>
